using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using HuiLian.Common.Input;
using HuiLian.Common.Output;
using HuiLian.Model.Platform;
using HuiLian.Service.Platform.MapLayer;
using HuiLian.Service.Platform.MapLayer.Input;

namespace HuiLian.Web.Controllers.Platform
{
    /// <summary>
    /// 地图加载的图层列表管理
    /// </summary>
    public class MapLayerController : AreaController
    {
        private readonly IMapLayerService _mapLayerServices;

        public MapLayerController(IMapLayerService mapLayerServices)
        {
            _mapLayerServices = mapLayerServices;
        }

        /// <summary>
        /// 查询单条地图加载的图层列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IResponseOutput> Get(long id)
        {
            return await _mapLayerServices.GetAsync(id);
        }

        /// <summary>
        /// 查询分页地图加载的图层列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> GetPage(PageInput<MapLayerEntity> model)
        {
            return await _mapLayerServices.PageAsync(model);
        }

        /// <summary>
        /// 新增地图加载的图层列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IResponseOutput> Add(MapLayerAddInput input)
        {
            return await _mapLayerServices.AddAsync(input);
        }

        /// <summary>
        /// 修改地图加载的图层列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> Update(MapLayerUpdateInput input)
        {
            return await _mapLayerServices.UpdateAsync(input);
        }

        /// <summary>
        /// 删除地图加载的图层列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IResponseOutput> SoftDelete(long id)
        {
            return await _mapLayerServices.SoftDeleteAsync(id);
        }

        /// <summary>
        /// 批量删除地图加载的图层列表
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IResponseOutput> BatchSoftDelete(long[] ids)
        {
            return await _mapLayerServices.BatchSoftDeleteAsync(ids);
        }
    }
}
